
package capa_persistencia;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CreadorBD 
{
    public static void main(String args[])
    {
        try 
        {
            Properties p = new Properties();
            String nomArch = "datos.properties";
            InputStream in;
            in = CreadorBD.class.getResourceAsStream(nomArch);
            p.load(in);
            String url = p.getProperty("url");
            String user = p.getProperty("user");
            String pass = p.getProperty("pass");
            in.close();
            
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection(url, user, pass);
            AccesoBD a = new AccesoBD();
            
            a.crearBD(con);
            con.close();
            
            con = DriverManager.getConnection(url + "partidasguardadas", user, pass);
            a.crearTablaEscenario(con);
            a.crearTablaPartidas(con);
            a.crearTablaActores(con);
            a.crearTablaPilotos(con);
            a.crearTablaAviones(con);
            a.crearTablaTanques(con);
            a.crearTablaDrones(con);
            a.crearTablaObstaculos(con);
            
            a.insertarEscenario(con, 1, "Gramilla");
            
            //Obstaculos del Escenario de Gramilla
            a.insertarObstaculo(con, 1, 147, 0, 45, 45, 't');
            a.insertarObstaculo(con, 1, 200, 3, 45, 45, 't');
            a.insertarObstaculo(con, 1, 181, 104, 45, 45, 't');
            a.insertarObstaculo(con, 1, 235, 107, 45, 45, 't');
            a.insertarObstaculo(con, 1, 164, 162, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 289, 107, 45, 45, 't');
            a.insertarObstaculo(con, 1, 242, 3, 45, 45, 't');
            a.insertarObstaculo(con, 1, 345, 2, 45, 45, 't');
            a.insertarObstaculo(con, 1, 357, 55, 45, 45, 't');
            a.insertarObstaculo(con, 1, 169, 111, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 224, 143, 45, 45, 't');
            a.insertarObstaculo(con, 1, 203, 195, 45, 45, 't');
            a.insertarObstaculo(con, 1, 147, 212, 45, 45, 't');
            a.insertarObstaculo(con, 1, 222, 315, 45, 45, 't');
            a.insertarObstaculo(con, 1, 490, 540, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 540, 0, 45, 45, 't');
            a.insertarObstaculo(con, 1, 965, 0, 45, 45, 't');
            a.insertarObstaculo(con, 1, 916, 2, 45, 45, 't');
            a.insertarObstaculo(con, 1, 895, 60, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1197, 190, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 1190, 94, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1190, 137, 45, 45, 't');
            a.insertarObstaculo(con, 1, 874, 0, 45, 45, 't');
            a.insertarObstaculo(con, 1, 564, 64, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1158, 181, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 1137, 233, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1094, 269, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1058, 191, 45, 45, 't');
            a.insertarObstaculo(con, 1, 862, 113, 45, 45, 't');
            a.insertarObstaculo(con, 1, 546, 640, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 598, 640, 45, 45, 't');
            a.insertarObstaculo(con, 1, 550, 625, 45, 45, 't');
            a.insertarObstaculo(con, 1, 576, 491, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1051, 640, 45, 45, 't');
            a.insertarObstaculo(con, 1, 493, 603, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 494, 640, 45, 45, 't');
            a.insertarObstaculo(con, 1, 203, 254, 45, 45, 't');
            a.insertarObstaculo(con, 1, 552, 113, 45, 45, 't');
            a.insertarObstaculo(con, 1, 617, 468, 45, 45, 't');
            a.insertarObstaculo(con, 1, 566, 284, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 173, 160, 45, 45, 't');
            a.insertarObstaculo(con, 1, 246, 123, 45, 45, 't');
            a.insertarObstaculo(con, 1, 295, 97, 45, 45, 't');
            a.insertarObstaculo(con, 1, 353, 109, 45, 45, 't');
            a.insertarObstaculo(con, 1, 190, 217, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 886, 30, 45, 45, 't');
            a.insertarObstaculo(con, 1, 846, 52, 45, 45, 't');
            a.insertarObstaculo(con, 1, 943, 47, 45, 45, 't');
            a.insertarObstaculo(con, 1, 902, 94, 45, 45, 't');
            a.insertarObstaculo(con, 1, 862, 142, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 1142, 162, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1191, 153, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1173, 232, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1048, 235, 45, 45, 't');
            a.insertarObstaculo(con, 1, 1090, 234, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 1091, 196, 45, 45, 't');
            a.insertarObstaculo(con, 1, 528, 523, 45, 45, 't');
            a.insertarObstaculo(con, 1, 624, 520, 45, 45, 't');
            a.insertarObstaculo(con, 1, 576, 546, 45, 45, 't');
            
            a.insertarObstaculo(con, 1, 72, 608, 44, 90, 'r');
            a.insertarObstaculo(con, 1, 118, 635, 34, 60, 'r');
            a.insertarObstaculo(con, 1, 161, 664, 176, 30, 'r');
            a.insertarObstaculo(con, 1, 899, 557, 147, 48, 'r');
            a.insertarObstaculo(con, 1, 891, 637, 35, 50, 'r');
            a.insertarObstaculo(con, 1, 927, 658, 45, 30, 'r');
            
            a.insertarObstaculo(con, 1, 1087, 609, 156, 90, 'w');
            a.insertarObstaculo(con, 1, 1135, 553, 108, 52, 'w');
            a.insertarObstaculo(con, 1, 1209, 502, 30, 30, 'w');
            a.insertarObstaculo(con, 1, 0, 0, 62, 697, 'w');
            a.insertarObstaculo(con, 1, 64, 303, 15, 273, 'w');
            a.insertarObstaculo(con, 1, 610, 0, 154, 93, 'w');
        } 
        catch (IOException | SQLException | ClassNotFoundException ex) 
        {
            Logger.getLogger(CreadorBD.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
